package com.itheima.annotation;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class TestAnnotation {
    @MyTest
    public  void test1(){
        System.out.println("test1");
    }
    public  void test2(){
        System.out.println("test2");
    }
    public  void test3(){
        System.out.println("test3");
    }


    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
        TestAnnotation s = new TestAnnotation();
        //1.获取class文件
        Class<TestAnnotation> testAnnotationClass = TestAnnotation.class;
        //2. 找方法
        Method[] declaredMethods = testAnnotationClass.getDeclaredMethods();
        for(Method method:declaredMethods){
            if(method.isAnnotationPresent(MyTest.class)){
                method.invoke(s);
            }
        }
    }
}
